import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/14 10:40
 * @description 找规律
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n <= 2) {
                System.out.println(-1);
            } else if (n % 2 == 1) {
                System.out.println(2);
            } else {
                if (n % 4 == 0) {
                    System.out.println(3);
                } else {
                    System.out.println(4);
                }
            }
        }
    }
}
